package com.situ.mall;

import org.junit.jupiter.api.Test;

import java.math.BigDecimal;

public class Demo {
    public static void main(String[] args) {
        double d1 = 0.1;
        double d2 = 0.2;
        double result = d1 + d2;
        System.out.println(result); //0.30000000000000004

        BigDecimal num1 = new BigDecimal("0.1");
        BigDecimal num2 = new BigDecimal("0.2");

        BigDecimal sum = num1.add(num2);
        BigDecimal product = num1.multiply(num2);

        System.out.println("Sum: " + sum); //Sum: 0.3
        System.out.println("Product: " + product);// Product: 0.02

        byte a = 127;
        byte b = 127;
        //b = a + b;// 报编译错误:cannot convert from int to byte
        b += a;
        System.out.println(b);// 等价于 b = (byte)(b + a);

        short s1 = 1;
        //s1 = s1 + 1;
    }


}